package com.sxy.mapper;

import com.sxy.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 宋鑫宇
 * @version 1.0
 */
public interface BrandMapper {
    /**
     * 查询所有
     */
    @Select("select * from tb_brand")
    @ResultMap("brandResultMap")
    List<Brand> selectAll();

    /**
     * 添加Brand数据
     */
    @Insert("insert into tb_brand values (null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);

    /**
     * 删除数据
     */
    @Delete("delete from tb_brand where id=#{id}")
    void deleteById(int id);

    /**
     * 修改数据，首先先回显数据，其次再进行修改
     */
    //回显数据
    @Select("select * from tb_brand where id = #{id}")
    @ResultMap("brandResultMap")
    Brand selectById(int id);

    //修改数据
    @Update("update tb_brand set brand_name=#{brandName},company_name=#{companyName}," +
            "ordered=#{ordered},description=#{description},status=#{status} where id=#{id}")
    void update(Brand brand);
}
